package com.yehuishou.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yehuishou.dao.PermissionDao;
import com.yehuishou.pojo.HUser;
import com.yehuishou.pojo.Permission;
import com.yehuishou.service.PermissionService;

/**
 * 
 * @author zxb
 *
 */

@Service
public class PermissionServiceImpl implements PermissionService {

	@Autowired
	private PermissionDao permissionDao;
	
	@Override
	public List<Permission> findByHUser(HUser huser) {
		
		return permissionDao.findByHUser(huser.getH_uid());
	}

	@Override
	public void perUpdate(Integer[] perid, Integer h_uid) {
		//admin权限不能修改
		if(h_uid !=1) {
			//先删除已有权限
			permissionDao.perDelete(h_uid);
			//添加权限
			for (int i : perid) {
				permissionDao.perAdd(i,h_uid);
			}
		}
		
	}

}
